<template>
  <div id="password-power-box">
    <div class="label">密码强度：</div>
    <div class="content">
      <div class="content-item" :class="psdPower > -1?'weak':''">
        <div class="process"></div>
        <div class="description">弱</div>
      </div>
      <div class="content-item" :class="psdPower > 0?'medium':''">
        <div class="process"></div>
        <div class="description">中</div>
      </div>
      <div class="content-item" :class="psdPower > 1?'strong':''">
        <div class="process"></div>
        <div class="description">强</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    power: {
      type: Number,
      default: 0    }
  },
  data() {
    return {
      psdPower: -1,
    }
  },
  watch:{
    power:{
      handler(val){
        this.psdPower = val;
      }
    }
  }
}
</script>
<style scoped lang="scss">
#password-power-box {
  display: flex;
  justify-content: space-around;
  align-items: center;

  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .content-item {
      display: flex;
      align-items: center;
      flex-direction: column;
      margin: .2rem .2rem;

      .process {
        width: 8rem;
        height: 1rem;
        border-radius: 1rem;
        background-color: #c9c9ca;
      }

    }

    $weak-color: #ee1f1f;
    $medium-color: #e2b048;
    $strong-color: #48e32d;

    .weak {
      color: $weak-color;

      .process {
        background-color: $weak-color;
      }
    }

    .medium {
      color: $medium-color;

      .process {
        background-color: $medium-color;
      }
    }

    .strong {
      color: $strong-color;

      .process {
        background-color: $strong-color;
      }
    }
  }
}
</style>